﻿#region Copyright Info

// 
// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.ComponentModel;
using Majesty_of_Omega.Model.Game;
using Majesty_of_Omega.Logic.Generator;
using Majesty_of_Omega.GUI.Controller;
#if NUNIT
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute;
#elif MBUNIT
using MbUnit.Framework;
using TestClass = MbUnit.Framework.TestFixtureAttribute;
using TestMethod = MbUnit.Framework.TestAttribute;
using TestInitialize = MbUnit.Framework.SetUpAttribute;
using TestCleanup = MbUnit.Framework.TearDownAttribute;
using ClassInitialize = MbUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = MbUnit.Framework.TestFixtureTearDownAttribute;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif


#endregion

namespace Test.Majesty_of_Omega
{
    /// <summary>
    ///This is a test class for TestGalaxyScreenController and is intended
    ///to contain all TestGalaxyScreenController Unit Tests
    ///</summary>
    [TestClass]
    public class TestGalaxyScreenController
    {
        private bool _propertyChangedTurnNumberFormattedInvoked;

        /// <summary>
        ///A test for the NextTurn Method of the GalaxyPageController
        ///</summary>
        [TestMethod]
        public void TestNextTurn()
        {
            _propertyChangedTurnNumberFormattedInvoked = false;
            SaveGame saveGame = TestDataGenerator.TestSaveGame;
            var galaxyScreenController = new GalaxyPageController(saveGame);
            galaxyScreenController.PropertyChanged += TestGamePlayController_PropertyChanged;
            galaxyScreenController.NextTurn();
            Assert.AreEqual(1, galaxyScreenController.Game.TurnNumber);
            Assert.AreEqual("Turn 001", galaxyScreenController.TurnNumberFormatted);
            Assert.IsTrue(_propertyChangedTurnNumberFormattedInvoked);
        }

        /// <summary>
        /// This delegate will be invoked, if the turn number property changed
        /// </summary>
        private void TestGamePlayController_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "TurnNumberFormatted")
                _propertyChangedTurnNumberFormattedInvoked = true;
        }

        /// <summary>
        /// Tests the create dummy game play controller function.
        /// </summary>
        [TestMethod]
        public void TestCreateDummyGamePlayController()
        {
            InGameController dummyGalaxyScreenController = GalaxyPageController.CreateDummyGamePlayController();
            Assert.IsNotNull(dummyGalaxyScreenController.Game);
            Assert.IsTrue(dummyGalaxyScreenController.Game.Galaxy.Stars.Count > 5);
        }

        ///// <summary>
        /////A test for GotoStarSystemPage
        /////</summary>
        //[TestMethod()]
        //public void TestGotoStarSystemPage()
        //{
        //    GalaxyPageController target = GalaxyPageController.CreateDummyGamePlayController(); // TODO: Initialize to an appropriate value
        //    StarSystemPage starSystemPage =  target.GotoStarSystemPage(target.Game.Galaxy.Stars[0]);
        //    Assert.IsNotNull(starSystemPage);
        //}
    }
}